package com.tendory.rxlocation;

import java.util.Date;

public class MyLocation {
    public static final int COORTYPE_WGS84 = 84;//gps
    public static final int COORTYPE_GCJ02 = 2;//gaode
    public static final int COORTYPE_BD09 = 9;

    public int coorType;
    public String time;
    public Date timeD;
    public double lon;
    public double lat;
    public double acc;
    public float direction;
    public float speed;
    public String add;
    public String city;
    public String district;
    public int locType;
    private Object orgLoc; //BDLocation

    public MyLocation() {
    }

    public MyLocation(double lon, double lat, double acc, String add, String city) {
        this.lon = lon;
        this.lat = lat;
        this.acc = acc;
        this.add = add;
        this.city = city;
    }

    public void setOrgLoc(Object loc) {
        this.orgLoc = loc;
    }

    public Object getOrgLoc() {
        return orgLoc;
    }

    public void convertToBd09() {
        if (coorType == COORTYPE_BD09) {
            return;
        }
        double[] r = GPSUtil.gcj02_To_Bd09(lat, lon);
        lat = r[0];
        lon = r[1];
        coorType = COORTYPE_BD09;
    }
    public void convertToGcj02() {
        if (coorType == COORTYPE_GCJ02) {
            return;
        }
        double[] r = GPSUtil.bd09_To_Gcj02(lat, lon);
        lat = r[0];
        lon = r[1];
        coorType = COORTYPE_GCJ02;
    }

    public float getRadius() {
        return (float) acc;
    }

    public float getDirection() {
        return direction;
    }

    public double getLatitude() {
        return lat;
    }

    public double getLongitude() {
        return lon;
    }

    public String getLocation() {
        String location = StringUtils.extractLocation(city, district);
        return location;
    }
}
